<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
            <title>Task</title>
            
            <link href="Style.css" rel="stylesheet" type="text/css" />
            <script src="jquery-1.7.2.min.js" type="text/javascript"></script>
            <script src="Common.js" type="text/javascript"></script>
            <script type="text/javascript">
                
                $(document).ready(function(){
                                  $("#refreshButton").bind("click", function(){
                                                           $("#errorDiv").html("刷新中...");
                                                           $.ajax({
                                                                  url: "http://testvms.yqphh.com/purchase/delivery/mine",
                                                                  data: {
                                                                  },
                                                                  type: "get",
                                                                  dataType: "json",
                                                                  
                                                                  error: function() {
                                                                  $("#errorDiv").html("刷新错误");
                                                                  },
                                                                  
                                                                  success: function(data) {
                                                                  if (data.result == "ok"){
                                                                  $("#errorDiv").html("");
                                                                  
                                                                  window.location.href = "Operation.html";
                                                                  }
                                                                  else{
                                                                  if (isRelogin(data.error_code)){
                                                                  return;
                                                                  }
                                                                  $("#errorDiv").html("error_code: " + data.error_code + "<br/>error_info: " + data.error_info);
                                                                  }
                                                                  }
                                                                  });
                                                           });
                                  $("#logoutButton").bind("click", function(){
                                                          
                                                          $("#errorDiv").html("登出中...");
                                                          $.ajax({
                                                                 url: "http://testvms.yqphh.com/purchase/driver/logout",
                                                                 data: {},
                                                                 type: "post",
                                                                 dataType: "json",
                                                                 
                                                                 error: function() {
                                                                 $("#errorDiv").html("登出错误");
                                                                 goToLoginPage();
                                                                 },
                                                                 
                                                                 success: function(data) {
                                                                 $("#errorDiv").html("");
                                                                 goToLoginPage();
                                                                 }
                                                                 });
                                                          });
                                  //$("#refreshButton").click();
                                  });
            </script>
            
            <style type="text/css">
                table{
                    height: 250px;
                }
            
            #refreshButton{
                font-size: 50px;
                background: #E74C3C;
                height: 200px;
            }
            
            #logoutButton{
                background: #2ECC71;
                height: 40px;
            }
                </style>
            </head>
    <body>
        <table cellpadding="0" cellspacing="0">
            <tr>
                <td>
                    <button id="refreshButton">刷新</button>
                </td>
            </tr>
            <tr>
                <td>
                    <button id="logoutButton">登出</button>
                </td>
            </tr>
            <tr>
                <td>
                    <div id="errorDiv"></div>
                </td>
            </tr>
        </table>
    </body>
</html>